package vo;
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


import java.io.Serializable;

import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

/**
 * Serialization class for Task 
 * @author jaje
 */


@XmlRootElement(name = "task")

@XmlType(propOrder = { "id", "name", "date", "status", "description", "attendant" })

public class Task implements Serializable {

	private static final long serialVersionUID = 1L;

	@XmlAttribute
	public String id;

	@XmlAttribute
	public String name;

	@XmlAttribute
	public String date;

	@XmlAttribute
	public String status;
	
	public String description;

	public String attendant;

	
	
	public Task() { //constructor for empty task
	}
	
	public Task(String id, String name, String date, String desc, String attendants) {
		this.id = id;
		this.name = name;
		this.date = date;
		this.status = "not-executed";
		this.description = desc;
		this.attendant = attendants;
	}
	
	public boolean impliesUser(String userId) {
		
		String[] attendants = attendant.split(",");
		for (String att : attendants) {
			if (att.trim().equalsIgnoreCase(userId)) return true;
		}
		
		return false;
	}
	
	public boolean equals(Task t) {
		
		if(!t.id.equals(this.id)) return false;
		else return true;
	}
	
	public boolean equals(String taskId){
		
		if (!taskId.equals(this.id)) return false;
		else return true;
	}
	
	public String toString() {
		
		return id + " , " + name + " , " + date + " , " + status + " , " + description + " , " + attendant;
	}

}





